package com.atguigu.config;

import com.atguigu.bean.Person;
import com.atguigu.dao.BookDao;
import org.springframework.context.annotation.*;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

/**
 * includeFilters，需要配合useDefaultFilters=false才能生效
 * excludeFilters，useDefaultFilters默认值为true就生效
 */
@Configuration
//@ComponentScan(value = {"com.atguigu"}, includeFilters = {
//        @ComponentScan.Filter(type = FilterType.ANNOTATION,classes = {Controller.class, Service.class})
//},useDefaultFilters = false)

@ComponentScans(value = {
        @ComponentScan(value = {"com.atguigu"}, includeFilters = {
                //@ComponentScan.Filter(type = FilterType.ANNOTATION,classes = {Controller.class, Service.class}),
                //@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE,classes = {BookDao.class}),
                @ComponentScan.Filter(type = FilterType.CUSTOM, classes = {MyTypeFilter.class})
        }, useDefaultFilters = false)
})
public class MainConfig {
    @Bean(value = "person") // 使用@Bean给容器中注册一个组件,类型是返回值类型，id默认是用方法名作为id
    public Person person01() {
        return new Person("liSi", 20);
    }
}
